package com.ruoyi.system.service.impl;

import java.util.List;

import com.ruoyi.system.domain.OaProjectInitiation;
import com.ruoyi.system.mapper.OaProjectInitiationMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.system.mapper.OaInitiationContractMapper;
import com.ruoyi.system.domain.OaInitiationContract;
import com.ruoyi.system.service.IOaInitiationContractService;

/**
 * 立项合同Service业务层处理
 *
 * @author ruoyi
 * @date 2025-03-12
 */
@Service
public class OaInitiationContractServiceImpl implements IOaInitiationContractService
{
    @Autowired
    private OaInitiationContractMapper oaInitiationContractMapper;
    @Autowired
    private OaProjectInitiationMapper oaProjectInitiation;

    /**
     * 查询立项合同
     *
     * @param id 立项合同主键
     * @return 立项合同
     */
    @Override
    public OaInitiationContract selectOaInitiationContractById(Long id)
    {
        return oaInitiationContractMapper.selectOaInitiationContractById(id);
    }

    /**
     * 查询立项合同列表
     *
     * @param oaInitiationContract 立项合同
     * @return 立项合同
     */
    @Override
    public List<OaInitiationContract> selectOaInitiationContractList(OaInitiationContract oaInitiationContract)
    {
        return oaInitiationContractMapper.selectOaInitiationContractList(oaInitiationContract);
    }

    /**
     * 新增立项合同
     *
     * @param oaInitiationContract 立项合同
     * @return 结果
     */
    @Override
    public int insertOaInitiationContract(OaInitiationContract oaInitiationContract)
    {
        OaProjectInitiation oaProjectInitiation1 = oaProjectInitiation.selectOaProjectInitiationByProjectNumber(oaInitiationContract.getNumber());
        oaInitiationContract.setInitiationId(oaProjectInitiation1.getId().toString());
        return oaInitiationContractMapper.insertOaInitiationContract(oaInitiationContract);
    }

    /**
     * 修改立项合同
     *
     * @param oaInitiationContract 立项合同
     * @return 结果
     */
    @Override
    public int updateOaInitiationContract(OaInitiationContract oaInitiationContract)
    {
        return oaInitiationContractMapper.updateOaInitiationContract(oaInitiationContract);
    }

    /**
     * 批量删除立项合同
     *
     * @param ids 需要删除的立项合同主键
     * @return 结果
     */
    @Override
    public int deleteOaInitiationContractByIds(Long[] ids)
    {
        return oaInitiationContractMapper.deleteOaInitiationContractByIds(ids);
    }

    /**
     * 删除立项合同信息
     *
     * @param id 立项合同主键
     * @return 结果
     */
    @Override
    public int deleteOaInitiationContractById(Long id)
    {
        return oaInitiationContractMapper.deleteOaInitiationContractById(id);
    }
}
